package FileIO;
import java.io.*;
import java.util.*;

public class FileIOFunctions {
	Date date = new Date();

	public FileIOFunctions() {

	}

	public void inputFile(File file, String contents) throws IOException {
		FileWriter writer = new FileWriter(file, true);
		PrintWriter input = new PrintWriter(writer);
		if (contents.length() <= 140) {
			input.println(date + ": " + contents);
			input.close();
		} else {
			FileIOGUI.updateDirections("That's too many characters!");
		}
	}

	public void outputFile() throws IOException {
		FileIOGUI.eraseJTextAreaOutput();
		BufferedReader in = new BufferedReader(new FileReader("output.txt"));
		String contents;
		while ((contents = in.readLine()) != null) {
			FileIOGUI.updateJTextAreaOutput(contents);
			FileIOGUI.updateJTextAreaOutput("\n\r");
		}

		FileIOGUI.updateDirections(contents);

	}

	public void copyFile() throws IOException {
		BufferedReader in = new BufferedReader(new FileReader("input.txt"));
		File file = new File("output.txt");
		PrintWriter input = new PrintWriter(new FileWriter(file, true));
		String contents;
		while ((contents = in.readLine()) != null) {
			input.println(contents);
		}
	}
}
